<?php

namespace App\Http\Requests;
/**
 * 后台菜单分组验证
 * @package App\Http\Requests
 */
class AdminSysMenuGroupPost extends AdminBaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $exceptId = (int) $this->input('group_id', 0);
        return [
            'group_key' => 'required|unique:sys_menu_groups,group_key,'.$exceptId.',group_id',
            'group_name' => 'required',
        ];
    }

    /**
     * 定义错误信息
     * @return array
     */
    public function messages()
    {
        return [
            'group_key.required' => '分组键名必填',
            'group_key.unique' => '分组键名已存在',
            'group_name.required' => '分组名必填',
        ];
    }
}
